package com.pug.service.userfav;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pug.mapper.hotel.UserFavHotelMapper;
import com.pug.pojo.Hotel;
import com.pug.pojo.KssUser;
import com.pug.pojo.UserFavHotel;
import com.pug.threadlocal.UserThreadLocal;
import com.pug.vo.UserHotelFavSearchVo;
import com.pug.vo.UserHotelFavVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author 飞哥
 * @Title: 学相伴出品
 * @Description: 飞哥B站地址：https://space.bilibili.com/490711252
 * 记得关注和三连哦！
 * @Description: 我们有一个学习网站：https://www.kuangstudy.com
 * @date 2022/4/26$ 20:50$
 */
@Slf4j
@Service
public class UserFavHotelServiceImpl extends ServiceImpl<UserFavHotelMapper, UserFavHotel> implements IUserFavHotelService {
    @Override
    public Page<Hotel> findUserFavHotelsPage(UserHotelFavSearchVo userHotelFavSearchVo) {
        KssUser kssUser = UserThreadLocal.get();
        Page<UserFavHotel> page = new Page<>(userHotelFavSearchVo.getPageNo(),userHotelFavSearchVo.getPageSize());
        QueryWrapper<Hotel> wrapper=new QueryWrapper<>();
//        wrapper.eq("user_id",kssUser.getId());   //后续对接口了在将这个打开
        return this.baseMapper.findUserFavHotelsPage(page,wrapper);
    }

    @Override
    public boolean isUserCollect(Long hotelId) {
        return false;
    }

    @Override
    public boolean savaUserFavHotel(UserHotelFavVo userHotelFavVo) {
        return this.baseMapper.savaUserFavHotel(userHotelFavVo);
    }

    @Override
    public boolean removeUserFavHotel(UserHotelFavVo userHotelFavVo) {
        return this.baseMapper.removeUserFavHotel(userHotelFavVo);
    }
}
